package com.zhongge.user;

import com.zhongge.book.BookList;
import com.zhongge.operations.*;

import java.util.Scanner;

@SuppressWarnings("all")//屏蔽所有警告
/**
 * @ClassName AdminUser
 * @Description TODO 管理员
 * @Author zhongge
 * @Date 2025/7/14 16:20
 * @Version 1.0
 */
public class AdminUser extends User{
    /**
     * 父类中有有参构造，则子类必须手动写出构造方法，
     * 然后在构造方法中调用父类的构造方法
     * @param name
     */
    public AdminUser(String name) {
        super(name);
        iOperation = new IOperation[]{
                new QuitSystem(), /*退出系统*/
                new SearchBook(), /*查找图书*/
                new AddBook(),    /*新增图书*/
                new DeleteBook(), /*删除图书*/
                new ShowBook()    /*显示图书*/
        };
    }

    @Override
    public int menu() {
        System.out.println("=========管理员菜单========");
        System.out.println("1. 查找图书");
        System.out.println("2. 新增图书");
        System.out.println("3. 删除图书");
        System.out.println("4. 显示图书");
        System.out.println("0. 退出系统");
        System.out.println("=========================");
        System.out.println("请输入你的操作：");
        Scanner sc = new Scanner(System.in);
        int choice = sc.nextInt();
        return choice;
    }

    @Override
    public void doIOperation(int choice, BookList bookList) {
        iOperation[choice].work(bookList);
    }
}
